<?php
declare (strict_types = 1);

namespace app\admin\model\user;

use app\admin\model\user\UserBill;
use think\Model;

/**
 * @mixin \think\Model
 */
class UserSign extends Model
{
    /**
     * 设置签到数据
     * @param $uid 用户uid
     * @param string $title 签到说明
     * @param int $number 签到获得积分
     * @param int $balance 签到前剩余积分
     * @return bool
     */
    public static function setSignData($uid, $title = '', $number = 0, $balance = 0)
    {
        $add_time = time();
        $sign_time = date('Y-m-d');
        return self::create(compact('uid', 'title', 'number', 'balance', 'add_time','sign_time')) &&
            UserBill::income($title, $uid,  $number,'integral', 'sign', 0);
    }
}
